<?php

/**
 * login form base class.
 *
 * @method login getObject() Returns the current form's model object
 *
 * @package    pendidikan indonesia
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 24171 2009-11-19 16:37:50Z Kris.Wallsmith $
 */
abstract class BaseloginForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'             => new sfWidgetFormInputHidden(),
      'id_user'        => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('user'), 'add_empty' => false)),
      'username'       => new sfWidgetFormInputText(),
      'password'       => new sfWidgetFormInputText(),
      'is_super_admin' => new sfWidgetFormInputCheckbox(),
      'date_join'      => new sfWidgetFormDateTime(),
      'last_login'     => new sfWidgetFormDateTime(),
      'id_pertanyaan'  => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('pertanyaanKeamanan'), 'add_empty' => true)),
      'jawaban'        => new sfWidgetFormInputText(),
    ));

    $this->setValidators(array(
      'id'             => new sfValidatorDoctrineChoice(array('model' => $this->getModelName(), 'column' => 'id', 'required' => false)),
      'id_user'        => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('user'))),
      'username'       => new sfValidatorString(array('max_length' => 100)),
      'password'       => new sfValidatorString(array('max_length' => 100)),
      'is_super_admin' => new sfValidatorBoolean(array('required' => false)),
      'date_join'      => new sfValidatorDateTime(array('required' => false)),
      'last_login'     => new sfValidatorDateTime(array('required' => false)),
      'id_pertanyaan'  => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('pertanyaanKeamanan'), 'required' => false)),
      'jawaban'        => new sfValidatorString(array('max_length' => 150, 'required' => false)),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorAnd(array(
        new sfValidatorDoctrineUnique(array('model' => 'login', 'column' => array('id_user'))),
        new sfValidatorDoctrineUnique(array('model' => 'login', 'column' => array('username'))),
        new sfValidatorDoctrineUnique(array('model' => 'login', 'column' => array('password'))),
      ))
    );

    $this->widgetSchema->setNameFormat('login[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'login';
  }

}
